package yolo

import (
	"appengine"
	"net/mail"
)

const (
)

type MailProcessor interface {
	ShouldProcess(c appengine.Context, msg *mail.Message) bool
	Process(c appengine.Context, msg *mail.Message)
}

var mailProcessors = make([]MailProcessor, 0)

func RegisterMailProcessor(mp MailProcessor) {
	mailProcessors = append(mailProcessors, mp)
}

func ProcessMail(c appengine.Context, msg *mail.Message) {
	for _, mp := range mailProcessors {
		if mp.ShouldProcess(c, msg) {
			mp.Process(c, msg)
			return
		}
	}
}
